package com.telchina.getui.config;

import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi;
import com.telchina.getui.util.PushUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: zlm
 * @Date: 2023/5/6
 * @Description: 个推配置信息
 * @Version: 1.0
 */
@Configuration
@Conditional(GeTuiConditional.class)
public class GeTuiConfiguration {

    @Bean
    @ConfigurationProperties(prefix = "getui")
    public GtApiConfiguration gtApiConfiguration() {
        return new GtApiConfiguration();
    }

    @Bean
    public PushApi pushApi() {
        // 实例化ApiHelper对象，用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(gtApiConfiguration());
        // 创建对象，建议复用。目前有PushApi、StatisticApi、UserApi
        return apiHelper.creatApi(PushApi.class);
    }

    @Bean
    public PushUtil pushUtil() {
        return new PushUtil();
    }
}
